
CREATE LANGUAGE plpgsql;


CREATE OR REPLACE FUNCTION public.ddlexec(query text)
RETURNS integer
AS $$
declare
  ret integer;
begin
  execute query;
  return 1;
  end;
$$ LANGUAGE plpgsql;


CREATE OR REPLACE FUNCTION public.ddlexec_and_query(stmt text, query text)
RETURNS SETOF record
AS $$
declare
   ret record;
begin
     execute stmt;
     for ret in execute query loop
     return next ret;
     end loop;
     return;
end;
$$ LANGUAGE plpgsql;


CREATE OR REPLACE FUNCTION public.dquery(query text)
RETURNS SETOF record
AS $$
declare
   ret record;
begin
   for ret in execute query loop
      return next ret;
   end loop;
   return;
end;
$$ LANGUAGE plpgsql;


CREATE OR REPLACE FUNCTION public.dquery_single(query text, node integer)
RETURNS SETOF record
AS $$
declare
   ret record;
begin
     for ret in execute query loop
     return next ret;
     end loop;
     return;
end;
$$ LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION public.dquery_single(query text, bcookie text)
RETURNS SETOF record
AS $$
declare
   ret record;
begin
     for ret in execute query loop
     return next ret;
     end loop;
     return;
end;
$$ LANGUAGE plpgsql;


